/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.hcht.xrlh.jcxx.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.hcht.xrlh.jcxx.entity.DrJcxx;
import com.hcht.xrlh.jcxx.service.DrJcxxService;

/**
 * 检查任务Controller
 * @author lrz
 * @version 2016-12-05
 */
@Controller
@RequestMapping(value = "${adminPath}/jcxx/drJcxx")
public class DrJcxxController extends BaseController {

	@Autowired
	private DrJcxxService drJcxxService;
	
	@ModelAttribute
	public DrJcxx get(@RequestParam(required=false) String id) {
		DrJcxx entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = drJcxxService.get(id);
		}
		if (entity == null){
			entity = new DrJcxx();
		}
		return entity;
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = {"list", ""})
	public String list(DrJcxx drJcxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<DrJcxx> page = drJcxxService.findPage(new Page<DrJcxx>(request, response), drJcxx); 
		model.addAttribute("page", page);
		return "xrlh/jcxx/drJcxxList";
	}

	@RequestMapping(value = {"list_jh", ""})
	public String list_jh(DrJcxx drJcxx, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<DrJcxx> page = drJcxxService.findPage(new Page<DrJcxx>(request, response), drJcxx); 
		model.addAttribute("page", page);
		return "xrlh/jcxx/drJcxx_jh_List";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "jhform")
	public String jhform(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_jh_Form";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "newtask_view")
	public String newtask_view(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_Form_add_view";
	}

	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "newtask_mod")
	public String newtask_mod(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_Form_add_mod";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "result_view")
	public String result_view(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_list_result_view";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "jhform_view")
	public String jhform_view(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_jh_Form_view";
	}

	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "jhform_zdy")
	public String jhform_zdy(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_jh_Form_zdy";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "zfryk")
	public String zfryk(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_zfryk";
		//return "modules/sys/userList_zj";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "zfdxk")
	public String zfdxk(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_zfdxk_1";
	}
	
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "zfdxk_add")
	public String zfdxk_add(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_zfdxk_2";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "zfdxk_mod")
	public String zfdxk_mod(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_zfdxk_3";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "zfjh_list")
	public String zfjh_list(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/zfjh_list";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "form")
	public String form(DrJcxx drJcxx, Model model) {
		model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxxForm";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "toK")
	public String toK(DrJcxx drJcxx, Model model) {
		//model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_k_Form";
	}

	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "newtask")
	public String newTask(DrJcxx drJcxx, Model model) {
		//model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_Form_add";
	}

	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "took")
	public String took(DrJcxx drJcxx, Model model) {
		//model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_list_ok";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "result_")
	public String result_(DrJcxx drJcxx, Model model) {
		//model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_list_result";
	}
	
	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "resultinput")
	public String resultinput(DrJcxx drJcxx, Model model) {
		//model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxx_result_form";
	}

	@RequiresPermissions("jcxx:drJcxx:view")
	@RequestMapping(value = "save_result")
	public String save_result(DrJcxx drJcxx, Model model) {
		//model.addAttribute("drJcxx", drJcxx);
		return "xrlh/jcxx/drJcxxList";
	}
	
	@RequiresPermissions("jcxx:drJcxx:edit")
	@RequestMapping(value = "save")
	public String save(DrJcxx drJcxx, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, drJcxx)){
			return form(drJcxx, model);
		}
		drJcxxService.save(drJcxx);
		addMessage(redirectAttributes, "保存检查任务成功");
		return "redirect:"+Global.getAdminPath()+"/jcxx/drJcxx/?repage";
	}
	
	@RequiresPermissions("jcxx:drJcxx:edit")
	@RequestMapping(value = "delete")
	public String delete(DrJcxx drJcxx, RedirectAttributes redirectAttributes) {
		drJcxxService.delete(drJcxx);
		addMessage(redirectAttributes, "删除检查任务成功");
		return "redirect:"+Global.getAdminPath()+"/jcxx/drJcxx/?repage";
	}

}